package com.cheer.ba.view.activity;

import android.support.v7.widget.CardView;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.cheer.ba.R;
import com.cheer.ba.constant.IntentKey;
import com.cheer.ba.model.OilDetailBannerModel;
import com.cheer.ba.model.OilDetailsModel;
import com.cheer.ba.utils.DensityUtils;
import com.cheer.ba.utils.ImageUtils;
import com.cheer.ba.utils.Protect;
import com.cheer.ba.view.base.BaseCommAty;

import java.util.List;

import butterknife.BindView;

/**
 * 描述 ：更多参考属性
 * 作者 ：hq
 * 时间 ：2017/7/1 17:03
 */
public class OilDetailTagAty extends BaseCommAty {

    @BindView(R.id.id_oil_detail_tags_linear)
    LinearLayout mLinear;

    //没有更多属性
    @BindView(R.id.id_no_more_tag_txt)
    TextView mTxtNoMoreData;

    private OilDetailsModel mOilDetailsModel;

    private int width;

    @Override
    public View loadView(LayoutInflater inflater, View childView) {
        return super.loadView(inflater, inflater.inflate(R.layout.aty_oil_detail_tag, null, false));
    }

    @Override
    public void initView() {
        width = DensityUtils.getScreenW(aty) * 2 / 3;
        setTitleText("参考属性");
        mOilDetailsModel = (OilDetailsModel) getIntent().getSerializableExtra(IntentKey.General.KEY_MODEL);
        if (null != mOilDetailsModel) {
            List<OilDetailBannerModel> mBanners = mOilDetailsModel.certificateList;
            if (null != mBanners && !mBanners.isEmpty()) {
                mTxtNoMoreData.setVisibility(View.GONE);
                for (OilDetailBannerModel model : mBanners) {
                    View mView = getLayoutInflater().inflate(R.layout.img_oil_detail_tag, null);
                    ImageView mImgView = (ImageView) mView.findViewById(R.id.id_tag_pic);
                    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(width, width);
                    mImgView.setLayoutParams(params);
                    ImageUtils.showImg(aty, Protect.setPic(model.fileUrl), R.color.color_F5F5F5, R.color.color_F5F5F5, mImgView);
                    mLinear.addView(mView);
                }
            } else {
                mTxtNoMoreData.setVisibility(View.VISIBLE);
            }
        } else {
            mTxtNoMoreData.setVisibility(View.VISIBLE);
        }
    }
}
